Shader "snowLerpSurf" {

Properties
{
    _Color ("Main Color", Color) = (1,1,1,1)
    _NormalMap ("Normal Map", 2D) = "bump" {}
    _Albedo ("Albedo", 2D) = "white" {}
    _SnowDirection ("SnowDirection", vector) = (0,1,0,1)
	_SnowStength("SnowStength", Range(0,20)) = 10
	_SnowDepth("SnowDepth", Range(0,0.5)) = 0.2
}
SubShader
{
    Tags {}

CGPROGRAM

#pragma surface surf Lambert vertex:vert


sampler2D _NormalMap;
sampler2D _Albedo;

float4 _SnowDirection;
fixed4 _Color;
float _SnowStength;
float _SnowDepth;

struct Input 
{
    float2 uv_Albedo;
    float2 uv_NormalMap;
    float3 worldNormal;
    INTERNAL_DATA
};

void surf (Input IN, inout SurfaceOutput o) 
{
    o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_NormalMap)).rgb;
	
    fixed3 worldNormal = WorldNormalVector(IN, o.Normal);

    float relevent = pow(saturate(dot(worldNormal, _SnowDirection.xyz)), 5) * _SnowStength;

    o.Albedo = _Color * relevent + tex2D(_Albedo, IN.uv_Albedo);
    o.Alpha = 1;
}

void vert(inout appdata_full v)
{
    float3 CameraN = mul(UNITY_MATRIX_IT_MV, _SnowDirection);

    float strength = saturate((dot(CameraN, v.normal)));

    v.vertex.xyz += v.normal * strength * _SnowDepth;
}

ENDCG
}
    FallBack "Diffuse"
}
